class HomeController < ApplicationController
  include Security::Session::Access

  def index
    @messages = Message.find_by_user(current_user)
    @pages = find_pages
    @documents = find_documents
  end

  private
    def find_pages
      pgs = []
      pages = Page.find(:all, :conditions => "is_featured = true", :order => "title")
      pages.each do |pg|
        pgs << pg if pg.show? && current_user_has_access?(pg.user_group_ids)
      end
      pgs
    end

    def find_documents
      docs = []
      documents = Document.find(:all, :conditions => "is_featured = true", :order => "title")
      documents.each do |doc|
        docs << doc if current_user_has_access?(doc.user_group_ids)
      end
      docs
    end
end
